<?php
require_once("../php/connection.php");

//$temp1 = mysql_query("SELECT * FROM site_groups WHERE `id`!='14'");
//while($row1 = mysql_fetch_array($temp1))
//{

$gpid = "22";

//deleting the meta row for that group
$res = mysql_query("DELETE FROM site_groups WHERE `id`='$gpid'");
if(!$res) echo mysql_error();

//deleting the member list for that group
$res = mysql_query("DELETE FROM site_group_members WHERE `gpid`='$gpid'");
if(!$res) echo mysql_error();

//deleting all the requests for that particular group
$res = mysql_query("DELETE FROM site_requests WHERE `gpid`='$gpid'");
if(!$res) echo mysql_error();


//before deleting the posts we need to delete all the requests made on that post
$temp = mysql_query("SELECT * FROM site_posts WHERE `type`='group_$gpid'");
if(!$temp) echo mysql_error();
while($row = mysql_fetch_array($temp))
{
	$postid = $row['id'];
	$res = mysql_query("DELETE FROM site_response WHERE `postid`='$postid'");
		if(!$res) echo mysql_error();
}

//deleting all the posts for that group
$res = mysql_query("DELETE FROM site_posts WHERE `type`='group_$gpid'");
if(!$res) echo mysql_error();

//deleting all the posts for that group
$res = mysql_query("DELETE FROM site_subscribe WHERE `gpid`='$gpid'");
if(!$res) echo mysql_error();

//}

?>